/*main.js*/

var app = new Vue({
	el:"#app",
	data:{
		show:false,
		checked: false,
		checkedNames: [],
		FamilyGroups: ["质量与客户满意科","新技术科","新材料科"],
		ReportDeparts:["印刷中心","后加工中心","综合产品","咭书(雅图仕)","咭书(湖南)","贺卡纸袋(雅图仕)","贺卡纸袋(越南)","精平装"],
		setProject:{},
		projects:[
		{
			"ProjectId":001,
			"ProjectName":"這是一個有長度的項目名稱，用於測試的",
			"FamilyGroup":"新材料科",
			"DepartInvolved":"print center",
			"liable":"aaronmo",
			"Background":"針對(****問題、****現用物料型號/名稱、****客人樣本效果、****工程單號/書名)的需求，研究/開發****達成****目的",
			"Targets":"1）質量目標：通過*****，改善****問題\n2）成本目標：從****方面綜合成本下降****萬/年<br>3）產品目標：通過開發****替代****，達到/符合****結果",
			"proWBS":[
			{
				"finish":false,
				"rNumber":1,
				"wbsName":"聯繫供應商提供小樣確認",
				"getTime":5,
				"planTime":"2022/1/25",
				"ActualTime":"2022/1/25",
				"result":"已完成《新物料關鍵檢測項目及參數標準書》并提供"
			},{
				"finish":false,
				"rNumber":2,
				"wbsName":"这是一个确认的内容",
				"getTime":5,
				"planTime":"2022/1/25",
				"ActualTime":"2022/1/25",
				"result":"已完成《新物料關鍵檢測項目及參數標準書》并提供"
			}
			]
		},
		{
			"ProjectId":002,
			"ProjectName":"project test2",
			"FamilyGroup":"新技术科",
			"DepartInvolved":"print center2",
			"liable":"aaronmo",
			"Background":"針對(****問題、****現用物料型號/名稱、****客人樣本效果、****工程單號/書名)的需求，研究/開發****達成****目的",
			"Targets":"1）質量目標：通過*****，改善****問題\n2）成本目標：從****方面綜合成本下降****萬/年\n3）產品目標：通過開發****替代****，達到/符合****結果"
		},
		{
			"ProjectId":003,
			"ProjectName":"project test3",
			"FamilyGroup":"新材料科",
			"DepartInvolved":"print center3",
			"liable":"aaronmo",
			"Background":"針對(****問題、****現用物料型號/名稱、****客人樣本效果、****工程單號/書名)的需求，研究/開發****達成****目的",
			"Targets":"1）質量目標：通過*****，改善****問題\n2）成本目標：從****方面綜合成本下降****萬/年\n3）產品目標：通過開發****替代****，達到/符合****結果"
		},
	]
		},
		methods:{
			changeAllChecked: function() {
			if (this.checked) {
				var checkedNames = this.projects[0].proWBS;
				for(let key in checkedNames){
					console.log(checkedNames[key])
					this.checkedNames.push(checkedNames[key].wbsName)
					console.log(this.checkedNames)
				}
			} else {
				this.checkedNames = []
			}

		},	
			test:function(e){
				console.log(e)
				this.setProject = e;
				this.show = true;
			}
			
		
	},
	watch: {
		"checkedNames": function() {
			if (this.checkedNames.length == this.projects[0].proWBS.length) {
				this.checked = true
			} else {
				this.checked = false
			}
		}
	}
})

